#ifndef UDPCONNMGR_HPP
#define UDPCONNMGR_HPP

#include "ConnMgr.hpp"

#include <netinet/in.h>

namespace kieper {
    class FindDevicesReply;

    class UdpConnMgr : public ConnMgr {
    public:
        UdpConnMgr(const char* host, unsigned int port);
        ~UdpConnMgr();
    protected:
    private:
        const char* host_;
        unsigned int port_;
        int serverSock_;
        int deviceSock_;
        
        static const unsigned int BUFFER_SIZE = 1600;
        char buffer_[BUFFER_SIZE];

        UdpConnMgr(const UdpConnMgr& other);
        UdpConnMgr& operator=(const UdpConnMgr& other);
        
        void doInitialize();
        void createServerSock();
        DeviceMapPtr doFindDevices();
        void doSend(const Device& device, const Packet& packet);
        IncomingPacket* doGetNextPacket();

        Device* makeDevice(const FindDevicesReply& msg, const sockaddr_in& devAddr); 
        
    };
}

#endif
